home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Shareware Grab Bag
/
Shareware Grab Bag.iso
/
002
/
wlabel.arc
/
WLABEL.C
< prev
next >
Wrap
Text File
|
1986-07-12
|
5KB
|
164 lines
/************************************************************************/
/* */
/* WINDOW LABEL MAKER */
/* */
/* VERSION 1.0 */
/* Compiled with Microsoft C ver 3.0 */
/* */
/* Written by Harold D. Maney, Jr. */
/* Xanatek Software Systems */
/* June 13, 1986 */
/* */
/************************************************************************/
#define LINT_ARGS 1
#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <conio.h>
#include <fcntl.h>
#include <windows.h>
#include <dos.h>
#include <wlabdef.h>
#include <stdlib.h>
main(argc,argv)
int argc;
char *argv[];
{
WINDOW *Lw, *Cw, *Tw;
FILE *Pr;
char c, *labelline, *editbuffer, nrlabels[6];
char prtfile[39];
int i, j, k, n, output, label, firstpass;
static int linelist[] = {0, 1, 2, 3, 4};
static int charswide = 30;
static int lineshigh = 5;
static int lpi = 6;
firstpass = TRUE;
Cw = wopen(0,0,25,80,DHDV+NOZOOM);
showlogo();
Lw = wopen(ctr(5,25),ctr(42,80),5,42,DHDV+NOZOOM);
wlabel(Lw,"[ LABEL OPTIONS ]",CENTER);
/* 123456789012345678901234567890123456789012 */
wprintf(Lw,"\n\n (M)ultiple names (one label each)");
wprintf(Lw,"\n (O)ne name (multiple labels)");
wprintf(Lw,"\n\n Please select option: ");
label = toupper(getch());
wclear(Lw);
wlabel(Lw,"[ OUTPUT OPTIONS ]",CENTER);
/* 123456789012345678901234567890123456789012 */
wprintf(Lw,"\n\n (F)ile output");
wprintf(Lw,"\n (P)rinter output");
wprintf(Lw,"\n\n Please select option: ");
output = toupper(getch());
if (output == 'F') {
wclear(Lw);
wprintf(Lw,"\nPlease enter filename: ");
wgetline(Lw,prtfile,39);
}
else
strcpy(prtfile,"LPT1");
wclose(Lw);
wclear(Cw);
Lw = wopen(ctr(lineshigh,25),ctr(charswide,80),lineshigh,charswide,DHDV);
wlabel(Lw,"[ Ctrl-End to Finish ]",CENTER);
do {
wclear(Lw);
Lw->editbuffer = 0;
wputatt(Lw,REVERSE,0,0,charswide);
do {
editbuffer = wedit(Lw,linelist,lineshigh);
}
while (editbuffer < (char *)256);
if (editbuffer == (char *)0xffff)
goto cleanup;
Tw = wopen(19,ctr(40,80),3,40,DHSV+NOZOOM);
if (label == 'O') {
wprintf(Tw,"\n How many labels do you need? <12>");
if (wgetline(Tw,nrlabels,5) == 0xffff) {
wclose(Tw);
goto cleanup;
}
n = atoi(nrlabels);
if (n == 0)
n = 12;
}
else
n = 1;
if ((output != 'F') && (firstpass || (label == 'O'))) {
wclear(Tw);
wprintf(Tw,"\n Prepare printer then press any key...");
if (getch() == ESC) {
wclose(Tw);
goto cleanup;
}
}
wclear(Tw);
hidecurs();
wprintf(Tw,"\n PRINTING...");
if (!(Pr = fopen(prtfile,"a"))) {
wprintf(Tw,"\nERROR - Cannot access printer or print file");
exit(2);
}
for (i=0; i<n; i++) {
labelline = strtok(strdup(editbuffer),"\x1f\0");
for (j=0,k=0; j<lineshigh; j++) {
if (strlen(labelline) > 2) {
fprintf(Pr,"%s\n",labelline);
k++;
}
labelline = strtok(NULL,"\x1f\0");
}
while (k++ < lpi)
fprintf(Pr,"\n");
}
fflush(Pr);
wclear(Tw);
showcurs(LINE);
if (label == 'O') {
wprintf(Tw,"\n Do it again? <Y>");
c = toupper(getch());
}
wclose(Tw);
fclose(Pr);
firstpass = FALSE;
free(Lw->editbuffer);
}
while ((c != 'N') && (c != ESC));
cleanup:
wclose(Lw);
wclose(Cw);
}
showlogo()
{
int h, w, l, t;
WINDOW *Lw;
h = 25;
w = 80;
l = 0;
t = 0;
for (t=0; t<9; t++) {
box(t,l,h,w,SHSV+NOZOOM);
l += 2;
h -= 2;
w -= 4;
}
Lw = wopen(10,19,5,42,BHBV+NOZOOM);
/* 123456789012345678901234567890123456789012 */
wprintf(Lw,"\n WindowLabel\n");
wprintf(Lw," A Label Maker by Harold D. Maney, Jr.\n\n");
wprintf(Lw," Please press any key...");
getch();
wclose(Lw);
}